package com.ktjiaoyu.springboothelloworld;

import com.ktjiaoyu.springboothelloworld.entity.User;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;

@SpringBootApplication
public class SpringbootHelloworldApplication {

    public static void main(String[] args) {
        //1.获取spring上下文
        ConfigurableApplicationContext context
                = SpringApplication.run(SpringbootHelloworldApplication.class, args);

        //2.获取对象
        User user = (User) context.getBean("user");
        //3.调用方法
        System.out.println(user.getUsername());
        System.out.println(user.getAge());

    }

}
